package com.open.capacity.exam.service.impl;

import com.open.capacity.common.exception.service.ServiceException;
import com.open.capacity.exam.dao.QuestionOptionDao;
import com.open.capacity.exam.service.QuestionOptionService;
import com.open.capacity.exam.vo.QuestionsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class QuestionOptionServiceImpl implements QuestionOptionService {
    @Autowired
    private QuestionOptionDao optionDao;

    /**
     * 添加选择考题时，新增选项
     * @param param
     * @return
     */
    @Override
    public Integer addOption(QuestionsVo param) {
        Integer optionId=optionDao.insert(param);
        if(optionId<=0){
            throw new ServiceException("选项添加异常");
        }
        return param.getQoptid();
    }

    /**
     * 修改选择考题的选项
     * @param param
     * @return
     */
    @Override
    public Integer editOption(QuestionsVo param) {
        return optionDao.update(param);
    }
}
